package cn.java.basic;

class JPerson
{
    protected int nAge;
    public char cGender;
    public String strName;
    private double dbWeight;    //私有数据成员
    private double dbHeight;    //私有数据成员
    public JPerson()
    {
        nAge=20;
        cGender='男';
        strName="无名氏";
        dbWeight=20;
        dbHeight=1;
    }
    public void work(){}
    protected double calcBMI()  //计算体重指数
    {
        double bmi=dbWeight/Math.sqrt(dbHeight);
        System.out.println(String.format("%s的BMI指数为%2.0f",strName,bmi));
        return bmi;
    }

}

public class JStudent extends JPerson
{
    public int nClassHour;
    public JStudent(int nAge,char cGender,String strName,int nClassHour)
    {
        this.nAge=nAge;
        this.cGender=cGender;
        this.strName=strName;
        this.nClassHour=nClassHour;
    }

    public JStudent()
    {
        super();
    }

    public void printInfo()
    {
        System.out.println("学生姓名："+strName+",年龄："+nAge+",性别："+cGender+",每周课时："+nClassHour);
        return;
    }

    public void work()
    {
        System.out.println("我的工作是学习");
    }

    public static void main(String[] args)
    {
        JStudent liu=new JStudent(19,'女',"一枝花",23);
        liu.printInfo();
        liu.calcBMI();
    }

}
